from Guanjianziqudong.Base import Base
import openpyxl,pytest
from selenium import webdriver

@pytest.fixture()
def driver():
    driver=webdriver.Edge()
    driver.maximize_window()
    yield driver
    driver.quit()

def test_login(driver):
    #获取表格
    work=openpyxl.load_workbook('gjz.xlsx')
    #读取excel
    excel=work['Sheet1']
    #初始化驱动
    base=Base(driver)
    #循环读取数据row单元格第几行l是列
    for row in excel.iter_rows(min_row=2,values_only=True):
        #读取关键字
        action =row[3]
        params={}
        #打开网址绿色的是表格的关键字
        if action == 'goto':
            params['url']=row[6]
        #定位元素
        elif action in ['send_keys','click','info']:
            params['loc']=[row[4],row[5]]
            print(row[4])
            print(row[5])

            if action == 'send_keys':
                params['info'] = row[6]

        method = getattr(base,str(action))
        method(**params)

